package cn.kgc.bean.vo;

/**
 * @author joy-survey team
 * @Description 状态码列表
 */
public enum ResultCodeEnum {
    SUCCESS("0000", "操作成功"),
    FAIL("0001", "操作失败"),

    SYS_ERROR("2001", "操作失败"),
    SYS_DB_DATA_NOT_EXIST("2001", "操作的数据不存在"),
    SYS_DB_DATA_EMPTY("2001", "没有数据"),
    SYS_CLASS_IS_BIND("2001", "班级已被使用，不能删除！"),
    SYS_QUESTIONNAIRE_IS_BIND("2001", "问卷已被使用，不能删除！"),
    SYS_CLASS_OR_QUESTIONNAIRE_STATUS_ERROR("2001", "班级或问卷状态错误！"),
    SYS_QUESTIONNAIRE_STATUS_NOT_ENABLE("2001", "问卷未启用"),
    SYS_CLASS_QUESTIONNAIRE_NOT_EXIST("2001", "调查问卷不存在！"),
    SYS_CLASS_QUESTIONNAIRE_NOT_START("2001", "问卷还未开始，请稍后再试"),
    SYS_CLASS_QUESTIONNAIRE_END("2001", "问卷已结束"),
    SYS_CLASS_QUESTIONNAIRE_IP_LIMIT("2001", "当前IP已参加过问卷评价，请勿重复提交"),
    SYS_FILE_SIZE_MAX_ERROR("2001", "上传文件过大"),
    SYS_FILE_NOT_EMPTY_ERROR("2001", "不能上传空文件"),
    SYS_PERMISSION_FORBIDDEN("2001", "您的账号没有该功能的访问权限，详情请联系系统管理员"),

    //请求参数错误
    PARAM_ERROR("1001", "请求参数错误"),
    PARAM_FILE_SIZE_OUT_OF_RANGE("1001", "文件大小超过范围"),
    PARAM_QUESTION_EMPTY("1001", "问题为空"),
    PARAM_QUESTIONNAIRE_TITLE_LEN_OUT_OF_RANGE("1001", "问卷名称长度超过范围"),
    PARAM_QUESTION_TITLE_LEN_OUT_OF_RANGE("1001", "问题题干长度超过范围"),
    PARAM_QUESTION_TITLE_EMPTY("1001", "序号为{0}的问题题干不可为空"),
    PARAM_OPTION_CONTENT_LEN_OUT_OF_RANGE("1001", "选项内容长度超过范围"),
    PARAM_OPTION_CONTENT_EMPTY("1001", "序号为{0}的问题选项{1}不可为空"),
    PARAM_QUESTION_OUT_OF_RANGE("1001", "问题数量超范围"),
    PARAM_QUESTION_NO_REPEAT("1001", "问题序号重复"),
    PARAM_QUESTION_NO_EMPTY("1001", "问题序号不可为空"),
    PARAM_QUESTION_NO_IS_NEGATIVE("1001", "问题序号不可为负数"),
    PARAM_QUESTION_NO_NOT_NUMBER("1001", "序号只能为数字"),
    PARAM_QUESTION_SCORE_ERROR("1001", "问题分数错误"),
    PARAM_QUESTION_SCORE_LEN_ERROR("1001", "序号为{0}的问题得分不完整"),
    PARAM_QUESTION_SCORE_EMPTY("1001", "序号为{0}的问题得分不可为空"),
    PARAM_CLASS_NAME_EXIST("1001", "班级名称不能重复"),
    PARAM_CLASS_QUESTIONNAIRE_STATUS_ERROR("1001", "班级评价问卷状态错误"),

    PARAM_SOURCE_TYPE_EMPTY("1001", "访问来源(source-type)空"),
    PARAM_EMPTY("1001", "请求必填参数为空"),
    PARAM_TIME_STAMP_EMPTY("1001", "时间戳(time-stamp)空"),

    // 登录错误
    PARAM_AUTH_ERROR("1001", "用户登录错误"),
    PARAM_AUTH_USER_NOT_EXIST("1010", "用户名不正确"),
    PARAM_AUTH_PASSWORD_ERROR("1011", "密码不正确"),
    PARAM_AUTH_ORIGIN_PASSWORD_ERROR("1001", "原密码不正确"),
    PARAM_AUTH_PASSWORD_DISAGREE("1001", "两次密码不一致"),

    PARAM_AUTH_NOT_LOGIN("1001", "用户登陆已过期"),
    PARAM_AUTH_TOKEN_EMPTY("1001", "Token空"),
    PARAM_AUTH_DISABLE("1001", "您的账号已被禁用，详情请联系系统管理员"),

    //用户注册错误
    PARAM_REGISTER_PHONE_ERROR("1001", "手机格式校验失败"),
    PARAM_REGISTER_PHONE_EXIST("1001", "手机号已经存在"),
    PARAM_REGISTER_PASSWORD_ERROR("1001", "密码校验失败"),
    PARAM_REGISTER_NEW_PASSWORD_ERROR("1001", "新密码效验失败");

    String code;
    String msg;

    ResultCodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }


    public static ResultCodeEnum getByCode(String code) {
        if (code == null) {
            return SYS_ERROR;
        }
        for (ResultCodeEnum outputEnum : ResultCodeEnum.values()) {
            if (code.equals(outputEnum.code)) {
                return outputEnum;
            }
        }
        return SYS_ERROR;
    }
}